// 搜索页相关的数据请求
import jsonp from '../../src/common/js/jsonp'
import {commonParams, options} from "./config";
import axios from 'axios';
// 获取搜索的热门关键词的数据
export function getSearchHotKey() {
    const url = '/api/getSearchHotKey'  //调用自定义的接口
 
     const data = Object.assign({}, {
       " g_tk": 5381,
        "loginUin": 1337312569,
        "hostUin": 0,
        "format": "json",
        "inCharset": "utf8",
        "outCharset": "utf-8",
        "notice": 0,
        "platform": "yqq.json",
        "needNewCode": 0  //使用的是axios,所以format使用的是json,不是jsonp
     })
 
     // return jsonp(url, data, options)
     return axios.get(url, {
         params: data
     }).then((res) => {
         return Promise.resolve(res.data) //es6新语法，返回一个以给定值解析后的Promise对象
     })
 }
//  获取检索的数据
export function getSearchResult(query,page,zhida,n) {
    const url = '/api/getSearchResult'  //调用自定义的接口
 
     const data = Object.assign({}, {
        "ct": 24,
        "qqmusic_ver": 1298,
        "new_json": 1,
        "remoteplace": "txt.yqq.center",
        "searchid": 41841455487525888,
        "t": 0,
        "aggr": 1,
        "cr": 1,
        "catZhida": zhida ? 1 : 0,
        "lossless": 0,
        "flag_qc": 0,
        "p": page,
        "n": n,
        "w": query,
        "g_tk": 5381,
        "loginUin": 1337312569,
        "hostUin": 0,
        "format": "json",
        "inCharset": "utf8",
        "outCharset": "utf-8",
        "notice": 0,
        "platform": "yqq.json",
        "needNewCode": 0//使用的是axios,所以format使用的是json,不是jsonp
     })
 
     // return jsonp(url, data, options)
     return axios.get(url, {
         params: data
     }).then((res) => {
         return Promise.resolve(res.data) //es6新语法，返回一个以给定值解析后的Promise对象
     })
 }